package work.chenbo.spring_boot_shiro.config.serializable;

import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;

/**
 * @className Jackson2ObjectMapperConfig
 * @authtor ChenBo
 * @date 2019/11/13
 */
@SpringBootConfiguration
public class Jackson2ObjectMapperConfig {

    /**
    * Jackson全局转化long类型为String
    * @author; ChenBo
    * @datetime: 2019/11/13
    */
    @Bean
    public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer(){
        return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder
                .serializerByType(Long.class, ToStringSerializer.instance)
                .serializerByType(Long.TYPE, ToStringSerializer.instance);


    }
}
